using Quartz;
using Zhaoxi.Zhihu.HotService.Core;
using Zhaoxi.Zhihu.HotService.Data;

namespace Zhaoxi.Zhihu.HotService.Jobs;

public class UpdateHotRankJob(
QuestionStatManager questionStatManager, HotRankManager hotRankManager) : IJob
{
    public static readonly JobKey Key = new(nameof(UpdateHotRankJob), nameof(HotService));
    public async Task Execute(IJobExecutionContext context)
    {
        var questionStats = questionStatManager.GetAndReset();
        if (questionStats == null) return;
        
        await hotRankManager. UpdateHotRankAsync(questionStats);
    }
}